<?php
/**
 * This file is part of the Agora distribution. 
 * Detailed copyright and licensing information can be found
 * in the gpl-3.0.txt file which should be included in the distribution.
 * 
 * @version		$Id: 3.0.14 Olympus 2010-09-28 rammstein4o $
 * @copyright  2007 - 2010 jVitals
 * @license   GPLv3 Open Source
 * @link       http://jvitals.com
 * @since      File available since initial release
 */
defined ('IN_AGORA') or die;

class AgoraPollsController extends AgoraController {
		
	function __construct() {
		parent::__construct();
		$this->loadDefaultView();

		$this->id = (int)Agora::getVar('id');

		if (!$this->id) {
			Agora::showError(Agora::lang('Bad request'));
			Agora::redirect(Agora::getRefferer());
		}
		$this->model = & Model::getInstance('PollModel');
	}

	function select() {
		$this->view->template = "poll/select";
	}

	function _execute() {
		$this->smilies = & Model::getInstance('SmiliesModel');
		$smilies = $this->smilies->loadAll();

		$this->view->assignRef('smilies',$smilies);

		$d = dir(AGORA_PATH.DS.'img'.DS.'icons');
		$topic_icons = array();
		while (($entry = $d->read()) !== false) {
			if (substr($entry, strlen($entry)-4) == '.gif') {
				$topic_icons[] = substr($entry, 0, strlen($entry)-4);
			}
		}
		$d->close();
		parent::_execute();
	}

}

$ptype = Agora::getVar('ptype');
if (!$ptype) $ptype = Agora::getPostVar('ptype','regular');

switch ($ptype) {
	case 'multi' : ainclude ('controller|polls|multi'); break;
	case 'multi_yes_no' : ainclude ('controller|polls|multi_yes_no'); break;
	case 'regular' : ainclude ('controller|polls|regular'); break;
}

?>
